package main.java.tmi.packing.service.impl;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import main.java.tmi.common.service.impl.AbstractDao;
import main.java.tmi.packing.service.PackingVO;

import org.springframework.stereotype.Repository;

/**
 * Asign Data Access Object
 *
 * @author min
 * @since 2010. 09. 10.
 */
@Repository
public class PackingDAO extends AbstractDao {
	
	public Map<String,String> getPackingView(Map<String,String> param){
    	
    	Map<String,String> returnMap ;
        returnMap = (Map<String,String>) selectByPk("PackingDAO.getPackingView", param);
        return returnMap;
    }
    
	public String mawbDupChk(String mawb) throws SQLException {
		String odrSeq = selectByPk("PackingDAO.mawbDupChk", mawb).toString(); 
		return odrSeq;
	}

	public String hawbDupChk(String hawb) throws SQLException {
		String odrSeq = selectByPk("PackingDAO.hawbDupChk", hawb).toString(); 
		return odrSeq;
	}
	

	//조회
	public List<PackingVO> getPackingDetailList(Map<String,String> param) throws SQLException {
		System.out.println("★★★★★★★★★★★★★★"+param.get("mawb"));
		System.out.println("★★★★★★★★★★★★★★"+param.get("hawb"));
		
		if(param.get("mawb").equals("") && param.get("hawb").equals("")){
			return (List<PackingVO>) list("PackingDAO.getPackingDetailList", param);
		}else{
			return (List<PackingVO>) list("PackingDAO.getPackingDetailAfterList", param);
		}
	}
	
	
	public void  addPacking(Map<String, String> param) throws SQLException {
		insert("PackingDAO.addPacking", param);
	}
	
	
	
	public int  deleteDoDet(Map<String, String> param) throws SQLException {
		return delete("PackingDAO.deleteDoDet", param);
	}
	
	public int  deleteDoHead(Map<String, String> param) throws SQLException {
		return delete("PackingDAO.deleteDoHead", param);
	}
	
	
	
	public int  modifyPacking(Map<String, String> param) throws SQLException {
		return update("PackingDAO.modifyPacking", param);
	}
	

    //등록
	public int addPackingDetail(Map<String, String> param) throws SQLException {
		System.out.println("==================================addpackingDetail param"+param );
		insert("PackingDAO.addPackingDetail", param);
		return 1;
	}
	
	//수정
	public int  packingDetailUpdate(Map<String, String> param) throws SQLException {
		return update("PackingDAO.packingDetailUpdate", param);
	}
	
	public int  delPackDetail(Map<String, String> param) throws SQLException {
		return delete("PackingDAO.delPackDetail", param);
	}
	
}
